<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<table width="400" border="1" id="table1">
</table>    
</body>
<script>
 //写出五行四列的表格，将帖子数组中数据填充到单元格中
var arr = [
        ["第2条帖子","a","第2条帖子填充到单元格中","2011.02.14"],
        ["第4条帖子","c","第4条帖子填充到单元格中","2011.02.01"],
        ["第3条帖子","b","第3条帖子填充到单元格中","2011.02.23"],
        ["第1条帖子","c","第1条帖子填充到单元格中","2011.02.08"],
        ["第5条帖子","b","第5条帖子填充到单元格中","2011.02.18"]
];
var tbheight = "500px";
var tbwidth = "800px";
document.write("<table border='1' height='"+ tbheight +"'width='"+tbwidth+"'>" )
function createList(arr){
    for(var i = 0;i <arr.length;i++){
        document.write("<tr>");
        for(var j = 0;j < arr[0].length;j++){
            if( j==2){
                arr[i][j] = arr[i][j].slice(0,5) +"...";
            }
            document.write("<td>");
            document.write(arr[i][j]);
            document.write("</td>");            
        }
        document.write("</tr>");
    }
    createList(arr);
    document.write("</table>");  
}
</script>
</html>